/*:
 * @target MZ
 * @author sun
 * @plugindesc 地图目的地光标
 * @help
 * 好像没啥好说的
 * 
 * @param Img
 * @text 资源
 * @type file
 * @require 1
 * @dir img/system
 * @desc 序列帧图像素材
 * @default cursor
 * 
 * @param Number Of Frames
 * @text 图片帧数
 * @type number
 * @min 0
 * @default 4
 * @desc 所用的序列帧动画图像的帧数
 * 
 * @param Animation Speed
 * @text 动画速度
 * @type number
 * @min 0
 * @default 6
 * @desc 序列帧动画间隔多少帧播放下一帧
 */

var Imported = Imported || {};
Imported.sun_MapCursor = true;

(() => {
    const sun_MapCursor = {};
    sun_MapCursor.parameters = PluginManager.parameters("sun_MapCursor");
    sun_MapCursor.fileName = String(sun_MapCursor.parameters["Img"]);
    sun_MapCursor.framesNum = Number(sun_MapCursor.parameters["Number Of Frames"] || 0);
    sun_MapCursor.speed = Number(sun_MapCursor.parameters["Animation Speed"] || 0);

    Sprite_Destination.prototype.createBitmap = function () {
        const { fileName } = sun_MapCursor;
        this.bitmap = ImageManager.loadSystem(fileName);
        this.anchor.x = 0.5;
        this.anchor.y = 0.5;
    }

    Sprite_Destination.prototype.updateAnimation = function () {
        const { framesNum, speed } = sun_MapCursor;
        const bitmap = this.bitmap;
        const index = Math.floor(this._frameCount / speed) % framesNum;
        const w = bitmap.width / framesNum;
        const h = bitmap.height;
        const x = w * index;
        const y = 0;
        this.setFrame(x, y, w, h);
        this._frameCount++;
    }
})()

